package com.example.softwareconfigurationcoursedesign;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

// 删除商品
@WebServlet("/deleteProduct")
public class DeleteProductServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 从请求参数获取商品ID
        int productId = Integer.parseInt(request.getParameter("productId"));

        // 在数据库中删除指定商品
        ProductService productService = new ProductService();
        productService.deleteProduct(productId);
        System.out.println("删除商品");

//        // 重定向到商品列表页面
//        response.sendRedirect("productList.jsp");
    }
}
